package paa.crawlers.delicious;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

public class DeliciousURL {
	
	private final String url;
	private final Set<String> tags;
	private Date urlDate;

	public DeliciousURL(String url) {
		this.url = url;
		this.tags = new HashSet<String>();
		this.urlDate = null;
	}
	
	public void addTag(String tag) {
		tags.add(tag);
	}
	
	public Set<String> getTags() {
		return tags;
	}
	
	public String getUrl() {
		return url;
	}
	
	@Override
	public String toString() {
		return url + " (" + getDate() + ") : " + tags;
	}
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((url == null) ? 0 : url.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		final DeliciousURL other = (DeliciousURL) obj;
		if (url == null) {
			if (other.url != null)
				return false;
		} else if (!url.equals(other.url))
			return false;
		return true;
	}

	public void setDate(Date urlDate) {
		this.urlDate = urlDate;
	}
	
	public Date getDate() {
		return urlDate;
	}
}
